package com.scproject.scbef.controller.study.hotpolitics;

import com.scproject.annotations.LoginVerifyToken;
import com.scproject.annotations.PassToken;
import com.scproject.dto.ResponseDto;
import com.scproject.scbef.pojo.HotPolitics;
import com.scproject.scbef.service.study.hotpolitics.HotPoliticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 时事政治
 * @author LNL
 * @date 2021/5/22 12:32
 */
@RestController
@Api(tags = "时事政治")
@RequestMapping("/hotpolitics")
public class HotPoliticsController {

    @Autowired
    private HotPoliticsService hotPoliticsService;

    /**
     * 获取所有的时事政治
     * @return
     */
    @GetMapping("/politics")
    @ApiOperation("获取所有时事政治")
    @PassToken
    public ResponseDto getAllHotPolitics() {
        ResponseDto responseDto = hotPoliticsService.getAllHotPolitics();
        return responseDto;
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("删除时事政治")
    @LoginVerifyToken
    public ResponseDto deleteHotPolitics(@ApiParam("删除时事政治id") @PathVariable("id") String id) {
        ResponseDto responseDto = hotPoliticsService.deleteHotPolitics(id);
        return responseDto;
    }

    @LoginVerifyToken
    @ApiOperation("添加时事政治")
    @PostMapping("/insert")
    public ResponseDto insertHotPolitics(@RequestBody HotPolitics hotPolitics, HttpServletRequest request){
        ResponseDto responseDto = hotPoliticsService.insertHotPolitics(hotPolitics,request);
        return responseDto;
    }

    @LoginVerifyToken
    @ApiOperation("修改时事政治")
    @PostMapping("/update")
    public ResponseDto updateHotPolitics(@RequestBody HotPolitics hotPolitics, HttpServletRequest request) {
        ResponseDto responseDto = hotPoliticsService.updateHotPolitics(hotPolitics,request);
        return responseDto;
    }


}

